package cn.com.gzheroli.bfw.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.gzheroli.bfw.pojo.base.TSDepart;
import cn.com.gzheroli.bfw.pojo.base.TSFunction;
import cn.com.gzheroli.core.common.mapper.CommonMapper;
import cn.com.gzheroli.core.common.mapper.FunctionMapper;
import cn.com.gzheroli.core.common.service.CommonService;
import cn.com.gzheroli.core.common.service.SystemService;
import cn.com.gzheroli.core.util.NameHandler;
import cn.com.gzheroli.core.util.MyBatisSqlUtils;
import cn.com.gzheroli.core.util.mybatis.SqlMapper;
import cn.com.gzheroli.service.bfw.FunctionService;

@Service("functionService")
public class FunctionServiceImpl  implements FunctionService{

	@Resource
	private FunctionMapper functionMapper;
	@Resource
	private  CommonService commonServie;
	@Resource
	private CommonMapper commonMapper;
	@Resource
	private SystemService systemService;
	@Autowired
	SqlMapper sqlMapper;
	public List<Map> getFunctionList(Map dataMap) {
		
		return functionMapper.getFunctionList(dataMap);
	}
	public List<Map> getFunctionMenuList(Map dataMap) {
		return functionMapper.getFunctionMenuList(dataMap);
	}
	@Override
	public Long getFunctionMenuCount(Map dataMap) {
		// TODO Auto-generated method stub
		return functionMapper.getFunctionMenuCount(dataMap);
	}
	@Override
	public List<Map> getMenuOptList(Map dataMap) {
		// TODO Auto-generated method stub
		return functionMapper.getMenuOptList(dataMap);
	}
	@Override
	public Long getMenuOptCount(Map dataMap) {
		// TODO Auto-generated method stub
		return functionMapper.getMenuOptCount(dataMap);
	}
	@Override
	public void updateFunction(TSFunction function) {
		commonServie.update(function);
	}
	@Override
	public void saveFunction(TSFunction function) {
		commonServie.save(function);
	}
	
	public TSFunction getFuncData(String id){
		String sql="select f.*,(select f2.FUNCTION_NAME from T_S_FUNCTION f2 where f.PARENT_ID=f2.id) FUNCTION_NAME";
		sql=sql+" from T_S_FUNCTION f where f.ID=#{id}";
		Map para=new HashMap();
		para.put("id", id);
		//return commonService.findOneObjForJdbc(sql, para, TSDepart.class);
		//return commonService.getEntity(sql, TSDepart.class, id);
		return sqlMapper.selectOne(sql, para, TSFunction.class);
	}
}
